package com.qianyu.project.mapper.provider.gs;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.util.ObjectUtils;

import java.util.Map;

/**
 * @author gs
 * @date create in 2021/2/2 9:37
 */
public class SubTenderDetailMapperProvider {

    public String selectPageList(IPage page, Map<String, String> params) {
        return new SQL() {
            {
                SELECT("std.*,stp.plan_editor,stp.date,pi.project_name");
                FROM("sub_tender_plan stp,sub_tender_detail std,project_info pi");
                WHERE("stp.id=std.subtender_id and stp.pro_id=pi.id");
                if (!ObjectUtils.isEmpty(params.get("planId"))) {
                    WHERE("stp.id like '%${params.planId}%'");
                }
                if (!ObjectUtils.isEmpty(params.get("subProject"))) {
                    WHERE("std.sub_project like '%${params.subProject}%'");
                }
                if (!ObjectUtils.isEmpty(params.get("subProviders"))) {
                    WHERE("std.sub_providers like '%${params.subProviders}%'");
                }
                if (!ObjectUtils.isEmpty(params.get("projectName"))) {
                    WHERE("pi.project_name like '%${params.projectName}%'");
                }
            }
        }.toString();
    }
}
